
import React from 'react'
import { Form, Input, Button, message } from 'antd';
import request from '../../utils/request'
import { useHistory } from "react-router-dom";



const formItemLayout = {
    labelCol: {
        xs: {
            span: 24,
        },
        sm: {
            span: 3,//控制label的框的长度
        },
    },
    wrapperCol: {
        xs: {
            span: 24,
        },
        sm: {
            span: 16,//控制文本框长度
        },
    },
};

const tailFormItemLayout = {
    wrapperCol: {
        xs: {
            span: 24,
            offset: 0,
        },
        sm: {
            span: 16,
            offset: 8,
        },
    },
};
const RegistrationForm = (props) => {
    const [form] = Form.useForm();
    let history = useHistory();
    const onFinish = (values) => {
        console.log(values, 'values');
        // const { uemail, captcha} = props;

        // let uemail = form.getFieldsValue().email
        let password = form.getFieldsValue().password
        // let captcha = form.getFieldsValue().captcha
        request.post("/orderList/nice/user/changePassword", {  password }).then(res => {
            console.log(res, 'youxiang')
            message.success('密码重置成功');
            // localStorage.setItem('token',res.data)
            history.push("/EmailLogin");
        })
    };



    return (
        <Form
            {...formItemLayout}
            form={form}
            name="register"
            onFinish={onFinish}
        >

                    <Form.Item
                        name="password"
                        label="密码"
                        rules={[
                            {
                                required: true,
                                message: '请设置新密码!',
                            },
                        ]}
                    >
                        <Input.Password />
                    </Form.Item>

            <Form.Item {...tailFormItemLayout}>
                {/* <Link to='/'> */}
                <Button htmlType="submit" style={{ width: '100%', background: '#fae100', outline: 'none', border: 0, height: '1rem' }}>
                    确定
                </Button>
                {/* </Link> */}
            </Form.Item>

        </Form>

    );

};
export default RegistrationForm
